﻿using KZ.Express.ENT;
using KZ.Express.Resource;
using KZ.Express.Task;
using KZ.Utilities;
using System;
using System.Collections.Generic;
using System.Data;

namespace KZ.Express.Presenter
{
    public class ZoneDetailPresenter : PresenterBase
    {
        private new ZoneTask _task;

        public ZoneDetailPresenter(IViewBase view)
            : base(view, new ZoneENT())
        {
            _view = view;
            _task = new ZoneTask();
        }

        public void LoadZoneDetail()
        {
            try
            {
                _view.SetMessage(String.Empty, true);
                base._view.Table = _task.LoadZoneDetail(base._view.Search);
            }
            catch (DataAccessException ex)
            {
                throw new BusinessLogicException(ex.Message);
            }
        }

        public void Save(List<DataRow> rows)
        {
            try
            {
                _view.EntityID = _task.Save(_view.Entity as ZoneENT, rows);
                _view.SetMessage(Message.BLM_SUC_SAVE.ToString(), true);
            }
            catch (DataAccessException ex)
            {
                throw new BusinessLogicException(ex.Message);
            }
        }
    }
}